<template>
  <div class="setting">
    <div class="tabs-left">
<!--      <div :class="['tab-item', tabActiveName === 'Subscription' ? 'active' : '']" @click="handleChangeTabName('Subscription')">Subscription</div>-->
      <div :class="['tab-item', tabActiveName === 'Integrations' ? 'active' : '']" @click="handleChangeTabName('Integrations')">Integrations</div>
    </div>
    <div class="tabs-content">
      <div class="content-title">{{ tabActiveName }}</div>
      <div class="content-list" v-show="tabActiveName === 'Subscription'">
        <div class="card-item">
          <h1>Basic</h1>
          <h2>USD $5/Month</h2>
          <ul>
            <li>10 Ideations/month</li>
            <li>View reports on Ideaio web page</li>
          </ul>
          <a-button class="select-btn" size="large" type="primary">SELECT</a-button>
        </div>
        <div class="card-item">
          <h1>Premium</h1>
          <h2>USD $10/Month</h2>
          <ul>
            <li>Unlimited <br />Ideations/month</li>
            <li>Eeport reports to Notion</li>
          </ul>
          <a-button class="select-btn" size="large" type="primary">SELECT</a-button>
        </div>
        <div class="card-item">
          <h1>Organization</h1>
          <h2></h2>
          <ul>
            <li>Please contact us via email</li>
          </ul>
          <a-button class="select-btn" size="large" type="primary">SELECT</a-button>
        </div>
      </div>
      <div class="integrations-list" v-show="tabActiveName === 'Integrations'">
        <span>Export the report to Notion after authorization.</span>
        <div style="display: flex">
          <a-button v-if="isConnected" style="margin-right: 10px" ghost type="danger" @click="onDisConnect">DISCONNECT</a-button>
          <a-button v-else ghost type="primary" @click="onConnect">CONNECT</a-button>
        </div>
      </div>
    </div>
    <a-modal v-model="visible" title=" ">
      <template #footer>

      </template>
      <a-card title="Notion" style="width: 100%">
        <template #extra>
          <span>dog's Notion</span>
        </template>
      </a-card>
    </a-modal>  </div>
</template>

<script>
import { Modal } from 'ant-design-vue'
import { ideaSetting } from "@/api/api";

export default {
  name: 'Index',
  data () {
    return {
      tabActiveName: 'Integrations',
      visible: false,
      isConnected: false
    }
  },
  created() {
    ideaSetting.checkNoticeConnect().then(res => {
      this.isConnected = res.result
    })
  },
  methods: {
    handleChangeTabName (tabActiveName) {
      this.tabActiveName = tabActiveName
    },
    onDisConnect () {
      Modal.confirm({
        title: () => 'Are you sure?',
        content: () => 'You are not able to export reports to Notion, still want to disconnect?',
        okText: 'Yes, disconnect me',
        cancelText: 'No, stay connected',
        onOk () {
          console.log('OK')
        },
        onCancel () {
          console.log('Cancel')
        }
      })
    },
    onConnect () {
      ideaSetting.connect()
    }
  }
}
</script>

<style scoped lang='less'>
.setting {
  width: 100%;
  display: flex;
  .tabs-left {
    width: 157px;
    height: 66px;
    background-color: #FFFFFF;
    .tab-item {
      height: 66px;
      border-left: 4px solid transparent;
      text-align: center;
      line-height: 66px;
      color: #3E4345;
      font-size: 14px;
      font-family: Quicksand500;
      font-weight: bold;
      cursor: pointer;
      &.active {
        color: #069697;
        border-color: #069697;
      }
    }
  }
  .tabs-content {
    flex-grow: 1;
    padding-left: 50px;
    padding-top: 30px;
    .content-title {
      font-size: 16px;
      font-family: Quicksand500;
      font-weight: bold;
      color: rgba(0, 0, 0, 0.87);
      line-height: 40px;
      margin-bottom: 50px;
    }
    .content-list {
      display: flex;
      .card-item {
        box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
        background: #FFFFFF;
        border-radius: 4px 4px 4px 4px;
        padding: 24px;
        width: 254px;
        height: 396px;
        margin-right: 50px;
        position: relative;
        h1 {
          font-size: 34px;
          font-family: Quicksand500;
          font-weight: bold;
          color: rgba(0, 0, 0, 0.87);
          line-height: 40px;
          text-align: center;
        }
        h2 {
          font-size: 24px;
          font-family: Quicksand500;
          font-weight: bold;
          color: #069697;
          line-height: 28px;
          text-align: center;
        }
        ul {
          padding-left: 14px;
          list-style: inherit;
        }
        li {
          font-size: 16px;
          font-family: Quicksand400;
          font-weight: 500;
          color: #3E4345;
          line-height: 24px;
        }
        .select-btn {
          position: absolute;
          right: 24px;
          bottom: 30px;
        }
      }
    }
  }
  .integrations-list {
    padding: 14px;
    background-color: #FFFFFF;
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    font-family: Quicksand400;
    font-weight: 400;
    color: #5E6366;
    line-height: 20px;
  }
}
</style>
